<template>
    <div class="app">
        <clientOnly>
            <div class="app-errors">
                <p>{{ props.error.message }}</p>
                <div class="button">
                    <Button @click="handleError">返回首页</Button>
                </div>
            </div>
        </clientOnly>
    </div>
</template>
<script setup lang="ts">
/**
 * 接收错误信息
 */
const props = defineProps({
    error: {
        type: Object,
        required: true
    }
})
/**
 * 清除错误信息并返回首页
 */
const handleError = () => {
    clearError({ redirect: '/' })
}
</script>
<style scoped lang="less">
.app-errors {
    position: fixed;
    top: 50%;
    left: 50%;
    line-height: 30px;
    text-align: center;
    transform: translateX(-50%) translateY(-50%);
    p:nth-child(1) {
        font-size: 12px;
        background-color: #f1f1f1;
        border-radius: 4px;
        color: #00a1d6;
        padding: 2px 10px;
        margin-bottom: 10px;
    }
    .button {
        display: flex;
        justify-content: center;
    }
}
</style>